package cn.xuchunh.campusbbs.widget;

import android.app.Fragment;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import cn.xuchunh.campusbbs.R;

/**
 * Created by XuChunH on 2015/10/22.
 */
public class SimpleItemView extends FrameLayout {

    private TextView label;
    private TextView content;

    public SimpleItemView(Context context) {
        super(context);
        init();
    }

    public SimpleItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }


    private void init() {
        View root = LayoutInflater.from(getContext()).inflate(R.layout.layout_simple_item_view, this, false);
        label = (TextView) root.findViewById(R.id.simple_item_label);
        content = (TextView) root.findViewById(R.id.simple_item_content);
        addView(root);
    }


    public void setContent(CharSequence text) {
        if (TextUtils.isEmpty(text)) {
            text = "N/A";
        }
        content.setText(text);
    }


    public void setLabel(CharSequence text) {
        if (TextUtils.isEmpty(text)) {
            text = "N/A";
        }
        label.setText(text);
    }
}
